 /*--------------------------------------------------------*
|                                                          |
| File: SKILLZ_Regression_analysis_final.do                |
| Last Modified By: Calvin Chiu                            |
| Last Modified Date: 10/13/2025	                       |
| Purpose: Tables and Figures for published manuscript     |
|                                                          |
 *---------------------------------------------------------*/

/***********************************************************
1. Constructing IPW weights

2. Descriptives
- Table 1: Baseline characteristics
- Table S1: Baseline characteristics by additional enrollment
- Table S6: Baseline characteristics comparing responders to non-responders for primary outcomes
- Table S8: Testing Rates at Graduation Event
- Table S9: Testing/Contraception at 6 vs 12 months
- Figure S3: Heterogenous treatment effects by school

3. Impact on HIV testing and contraception (Table 2)

4. Impact on adoption/discontinuation (Table 3)

5. Impact on specific testing modalities and contraceptive methods (Table 4)

6. Appendices
- Table S2: Additional methods
- Table S4: Restricting to Baseline only
- Table S5: Non-response bias
- Table S7: Timing of enrollment
- Table S3: Diff-in-diff

 ************************************************************/
set more off

global project       		"C:\Users\cchiu6\Dropbox\Research\SKILLZ\Data\12 Month Follow Up"


global dofiles       		"${project}\dofiles"
global dtafiles      		"${project}\dtafiles"
global cleaneddata			"${project}\cleaneddata"
global logfiles      		"${project}\logfiles"
global rawdata       		"${project}\rawdata" 
global tables        		"${project}\tables"
global figures        		"${project}\figures"

global dataset				"${cleaneddata}\SKILLZ_analysis_final.dta"

log using "${project}\logfiles\SKILLZ_Regression_analysis_`c(current_date)'.smcl", replace

 ************************************************************

 
 ************ *1. Constructing IPW weights************************************************************
use "${dataset}", clear  
 
* Defining adherence to per-protocol
	//Attending at least one session according to GRS data
gen per_protocol_treat2=0
	replace per_protocol_treat=1 if TotalSessionsAttended>0 & TotalSessionsAttended!=.
	
	tab per_protocol_treat2 treat, col
	lab var per_protocol_treat2 "Attended at least 1 session of SKILLZ"

	
	//Attending at least 8 sessions according to GRS data
gen per_protocol_treat=0
	replace per_protocol_treat=1 if TotalSessionsAttended>=8 & TotalSessionsAttended!=.
	
	tab per_protocol_treat treat, col
	lab var per_protocol_treat "Attended at least 8 sessions of SKILLZ"

* Estimating IPW weights

	//a) Select Baseline characteristics
	gen bs_test_pos=0 if bs_hiv_status!=.
		replace bs_test_pos=1 if bs_hiv_status==1
	
local baseline_var age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_test_pos
	
	//Table 1: Balance
		//Total number of sexual partners
	tabstat bs_num_partners_ever, stat(mean sd p25 p50 p75 IQR n)
	tabstat bs_num_partners_ever if treat==1, stat(mean sd p25 p50 p75 IQR n)
	tabstat bs_num_partners_ever if treat==0, stat(mean sd p25 p50 p75 IQR n)

	
		//Checking for balance using regression tests
	foreach var in `baseline_var'{
		eststo: reg `var' i.treat, cluster(school)
	}
	esttab using "${tables}\Balance_TrtCtr", p replace
	eststo clear
	
	//Fixing denominators for select variables - imputing means
	foreach var of varlist `baseline_var'{
		ds `var'
		count if `var'==.
	}
	
	foreach var of varlist `baseline_var' {
		// Calculate the mean of the variable, excluding missing values
		quietly summarize `var', meanonly
		local mean = r(mean)
		
		// Replace missing values with the calculated mean
		replace `var' = `mean' if missing(`var')
	}

	
	//Checking for balance using regression tests (after fixing denominators)
	foreach var in `baseline_var'{
		eststo: reg `var' i.treat, cluster(school)
	}
	esttab using "${tables}\Balance_TrtCtr2", p replace
	eststo clear
	

	
* Predict IPW
* Estimate probablity of per protocol for numerator of stabilized IPW
logit per_protocol_treat
predict PP_tx_IPW, pr

* Estimate conditional probablity of per protocol tx for denominator of stabilized IPW
logit per_protocol_treat `baseline_var'
predict PP_tx_cond_IPW, pr

* Create stabilized IPWs for each arm (control arm == 1)
gen stabIPW = 1
replace stabIPW = (PP_tx_IPW/PP_tx_cond_IPW) if treat==1
replace stabIPW = (1-PP_tx_IPW)/(1-PP_tx_cond_IPW) if treat==0

* Check descriptives for stabilized IPW
summ stabIPW if treat==1 // N=1134, mean=1.01, SD=0.24, range 0.41-3.50

* Check descriptives for denominator
summ PP_tx_cond_IPW // range does not include 0,1

* Check standardized differences after stabilized IPW
covbal per_protocol_treat `baseline_var' if treat==1, wt(stabIPW) // should not be higher than 0.1


//Create attrition weights
	gen HIV_6mth_resp=0
		replace HIV_6mth_resp=1 if hiv_test_recent!=.
	gen fp_6mth_resp=0
		replace fp_6mth_resp=1 if fp_use_recent!=.
	gen HIV_12mth_resp=0
		replace HIV_12mth_resp=1 if fu_hiv_test_recent!=.
	gen fp_12mth_resp=0
		replace fp_12mth_resp=1 if fu_fp_use_recent!=.	
		
//a) 6 mth HIV
	drop PP_tx_IPW PP_tx_cond_IPW

	* Predict IPW
	* Estimate probablity of per protocol for numerator of stabilized IPW
	logit HIV_6mth_resp
	predict PP_tx_IPW, pr

	* Estimate conditional probablity of per protocol tx for denominator of stabilized IPW
	logit HIV_6mth_resp `baseline_var'
	predict PP_tx_cond_IPW, pr

	* Create stabilized IPWs for each arm (control arm == 1)
	gen stabIPW_HIV_6mth = (PP_tx_IPW/PP_tx_cond_IPW)

//b) 6 mth FP
	drop PP_tx_IPW PP_tx_cond_IPW

	* Predict IPW
	* Estimate probablity of per protocol for numerator of stabilized IPW
	logit fp_6mth_resp
	predict PP_tx_IPW, pr

	* Estimate conditional probablity of per protocol tx for denominator of stabilized IPW
	logit fp_6mth_resp `baseline_var'
	predict PP_tx_cond_IPW, pr

	* Create stabilized IPWs for each arm (control arm == 1)
	gen stabIPW_fp_6mth = (PP_tx_IPW/PP_tx_cond_IPW)

//c) 12 mth HIV
	drop PP_tx_IPW PP_tx_cond_IPW

	* Predict IPW
	* Estimate probablity of per protocol for numerator of stabilized IPW
	logit HIV_12mth_resp
	predict PP_tx_IPW, pr

	* Estimate conditional probablity of per protocol tx for denominator of stabilized IPW
	logit HIV_12mth_resp `baseline_var'
	predict PP_tx_cond_IPW, pr

	* Create stabilized IPWs for each arm (control arm == 1)
	gen stabIPW_HIV_12mth = (PP_tx_IPW/PP_tx_cond_IPW)	
	

//d) 12 mth FP
	drop PP_tx_IPW PP_tx_cond_IPW

	* Predict IPW
	* Estimate probablity of per protocol for numerator of stabilized IPW
	logit fp_12mth_resp
	predict PP_tx_IPW, pr

	* Estimate conditional probablity of per protocol tx for denominator of stabilized IPW
	logit fp_12mth_resp `baseline_var'
	predict PP_tx_cond_IPW, pr

	* Create stabilized IPWs for each arm (control arm == 1)
	gen stabIPW_fp_12mth = (PP_tx_IPW/PP_tx_cond_IPW)
	
keep ptid per_protocol_treat per_protocol_treat2 stabIPW stabIPW_HIV_6mth stabIPW_fp_6mth stabIPW_HIV_12mth stabIPW_fp_12mth 

lab var stabIPW "Stabilized IPW weights for per protocol"
lab var stabIPW_HIV_6mth "Stabilized IPW weights for response to 6mth HIV testing"
lab var stabIPW_fp_6mth "Stabilized IPW weights for response to 6mth contraception"
lab var stabIPW_HIV_12mth "Stabilized IPW weights for response to 12mth HIV testing"
lab var stabIPW_fp_12mth "Stabilized IPW weights for response to 12mth contraception"

tempfile IPW_weights
save `IPW_weights', replace


 ************ *2. Descriptives************************************************************
use "${dataset}", clear  

//Merging in IPW weights
merge 1:1 ptid using `IPW_weights', nogen 
 
//Estimating ICC for primary outcomes (Table 2)
loneway bs_hiv_test_recent school
loneway bs_fp_use_recent school
loneway hiv_test_recent school
loneway fu_hiv_test_recent school
loneway fp_use_recent school
loneway fu_fp_use_recent school

//Table 1: Baseline characteristics
tab bs_hiv_status, gen(bs_hiv_pos)
tab hiv_status, gen(hiv_pos)

	//Continuous
	estpost tabstat age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if baseline==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Table 1")
	eststo clear
	
	estpost tabstat age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if baseline==1 & treat==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Table 1: Control")
	eststo clear
	
	estpost tabstat age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if baseline==1 & treat==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Table 1: Treatment")
	eststo clear

	estpost ttest age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if baseline==1, by(treat)	
	esttab, p lab varwidth(60) wide	


	qui: estpost tabstat bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 if baseline==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Table 1") varwidth(60)

	qui: estpost tabstat bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 if baseline==1 & treat==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Table 1: Control") varwidth(60)
	
	qui: estpost tabstat bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 if baseline==1 & treat==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Table 1") varwidth(60)
	
	estpost ttest bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2, by(treat)	
	esttab, p lab varwidth(60) wide			
	
	foreach var of varlist bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2{
		eststo: reg `var' i.treat i.school, cluster(school)
	}
	esttab, drop(*school*)
	eststo clear	
 
 	foreach var of varlist bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2{
		eststo: reg `var' i.treat, cluster(school)
	}
	esttab
	eststo clear
	
//Table S1: Baseline characteristics by additional enrollment
preserve
	
	keep if treat==1
	
	tab add_enrol if sur_complete==1
	
	tab school add_enrol 
 
	//Continuous
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix Table 1")
	eststo clear
	
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1 & add_enrol==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix Table 1: Baseline cohort")
	eststo clear
	
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1 & add_enrol==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix Table 1: Additional recruit")
	eststo clear

	estpost ttest age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1, by(add_enrol)	
	esttab, p lab varwidth(60) wide	


	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2 if followup_6_mth==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix Table 1") varwidth(60)

	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2 if followup_6_mth==1 & add_enrol==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix Table 1: Baseline cohort") varwidth(60)
	
	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2 if followup_6_mth==1 & add_enrol==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix Table 1: Additional recruit") varwidth(60)
	
	estpost ttest employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2, by(add_enrol)	
	esttab, p lab varwidth(60) wide		

	
	//Balance tests
	foreach var of varlist age_6mth hiv_know_tot num_partners_ever shreya_score{
		qui eststo: reg `var' i.add_enrol if sur_complete==1, cluster(school)
	}
	esttab, p
	eststo clear
	
	foreach var of varlist employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2{
		qui eststo: reg `var' i.add_enrol if sur_complete==1, cluster(school)
	}
	esttab, p
	eststo clear	
	
	foreach var of varlist employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2{
		qui eststo: logit `var' i.add_enrol if sur_complete==1, cluster(school)
	}
	esttab, p
	eststo clear	
 
 	//Omnibus tests
	keep if sur_complete==1
	
		*Imputing means and generating dummies
	reg add_enrol age_6mth hiv_know_tot num_partners_ever shreya_score employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2, cluster(school)
		testparm *	
	
	
restore 

preserve
	
	keep if treat==0
	
	tab add_enrol if sur_complete==1
 
 	tab school add_enrol 
 
	//Continuous
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix Table 1")
	eststo clear
	
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1 & add_enrol==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix Table 1: Baseline cohort")
	eststo clear
	
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1 & add_enrol==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix Table 1: Additional recruit")
	eststo clear

	estpost ttest age_6mth hiv_know_tot num_partners_ever shreya_score if sur_complete==1, by(add_enrol)	
	esttab, p lab varwidth(60) wide	


	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2 if followup_6_mth==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix Table 1") varwidth(60)

	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2 if followup_6_mth==1 & add_enrol==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix Table 1: Baseline cohort") varwidth(60)
	
	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2 if followup_6_mth==1 & add_enrol==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix Table 1: Additional recruit") varwidth(60)
	
	//Balance tests
	foreach var of varlist age_6mth hiv_know_tot num_partners_ever shreya_score{
		qui eststo: reg `var' i.add_enrol if sur_complete==1, cluster(school)
	}
	esttab, p
	eststo clear
	
	foreach var of varlist employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2{
		qui eststo: reg `var' i.add_enrol if sur_complete==1, cluster(school)
	}
	esttab, p
	eststo clear	
 
 	foreach var of varlist employed_income food_insecure sex_ever gift_sex_recent fp_use_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent hiv_pos2{
		qui eststo: logit `var' i.add_enrol if sur_complete==1, cluster(school)
	}
	esttab, p
	eststo clear	
 
restore
 
//Table S6: Baseline characteristics comparing responders to non-responders for primary outcomes
* Comparing descriptive characteristics by outcome missingness

//1) 6-mths
preserve

keep if sur_complete==1

//Missing HIV response
gen hiv_test_recent_miss=0
	replace hiv_test_recent_miss=1 if hiv_test_recent==.
 
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if hiv_test_recent_miss==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if hiv_test_recent_miss==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent fp_use_recent if hiv_test_recent_miss==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent fp_use_recent if hiv_test_recent_miss==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	estpost ttest age_6mth hiv_know_tot num_partners_ever shreya_score employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any, by(hiv_test_recent_miss)	
	esttab, p lab varwidth(60) wide nostar
 
 	//Balance tests
	foreach var of varlist age_6mth hiv_know_tot num_partners_ever shreya_score employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any{
		qui eststo: reg `var' i.treat i.hiv_test_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear

	foreach var of varlist employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any{
		qui eststo: logit `var' i.treat i.hiv_test_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear
	
 
//Missing FP response
gen fp_use_recent_miss=0
	replace fp_use_recent_miss=1 if fp_use_recent==.
 
 
	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if fp_use_recent_miss==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	estpost tabstat age_6mth hiv_know_tot num_partners_ever shreya_score if fp_use_recent_miss==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent fp_use_recent if fp_use_recent_miss==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	qui: estpost tabstat employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any hiv_test_recent fp_use_recent if fp_use_recent_miss==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	estpost ttest age_6mth hiv_know_tot num_partners_ever shreya_score employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any, by(fp_use_recent_miss)	
	esttab, p lab varwidth(60) wide nostar
 
 	//Balance tests
	foreach var of varlist age_6mth hiv_know_tot num_partners_ever shreya_score employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any{
		qui eststo: reg `var' i.treat i.fp_use_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear
	
 	foreach var of varlist employed_income food_insecure sex_ever gift_sex_recent ever_preg preg_test friend_preg friend_abortion sti_symp_any{
		qui eststo: logit `var' i.treat i.fp_use_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear
 
restore
 
//2) 12-mths
preserve

keep if fu_sur_complete==1

//Missing HIV response
gen hiv_test_recent_miss=0
	replace hiv_test_recent_miss=1 if fu_hiv_test_recent==.
 
	estpost tabstat age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score if hiv_test_recent_miss==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	estpost tabstat age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score if hiv_test_recent_miss==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	qui: estpost tabstat fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any if hiv_test_recent_miss==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	qui: estpost tabstat fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any if hiv_test_recent_miss==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	estpost ttest age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any, by(hiv_test_recent_miss)	
	esttab, p lab varwidth(60) wide nostar
 
 	//Balance tests
	foreach var of varlist age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any{
		qui eststo: reg `var' i.treat i.hiv_test_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear
	
	foreach var of varlist fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any{
		qui eststo: logit `var' i.treat i.hiv_test_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear


 
//Missing FP response
gen fp_use_recent_miss=0
	replace fp_use_recent_miss=1 if fu_fp_use_recent==.
 
 
	estpost tabstat age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score if fp_use_recent_miss==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	estpost tabstat age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score  if fp_use_recent_miss==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Appendix non-response table")
	eststo clear
 
 	qui: estpost tabstat fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any if fp_use_recent_miss==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	qui: estpost tabstat fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any if fp_use_recent_miss==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Appendix non-response table") varwidth(60)
 
 	estpost ttest age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any, by(fp_use_recent_miss)	
	esttab, p lab varwidth(60) wide nostar
 
 	//Balance tests
	foreach var of varlist age_12mth fu_hiv_know_tot fu_num_partners_ever fu_shreya_score fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any{
		qui eststo: reg `var' i.treat i.fp_use_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear
 
	foreach var of varlist fu_employed_income fu_food_insecure fu_sex_ever fu_gift_sex_recent fu_ever_preg fu_preg_test fu_friend_preg fu_friend_abortion fu_sti_symp_any{
		qui eststo: logit `var' i.treat i.fp_use_recent_miss, cluster(school)
	}
	esttab, p
	eststo clear 
 
 
restore

//Table S6: Descriptive statistics on attrition

* Retention at 6 months
keep if bs_sur_complete==1

tab sur_complete
tab fu_sur_complete

	estpost tabstat age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if sur_complete==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Retained at 6 mths")
	eststo clear
	
	estpost tabstat age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if sur_complete==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("LTFU at 6 mths")
	eststo clear

	qui: estpost tabstat bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 if sur_complete==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Retained at 6 mths") varwidth(60)

	qui: estpost tabstat bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 if sur_complete==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("LTFU at 6 mths") varwidth(60)
	
	 estpost ttest age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 , by(sur_complete)	
	esttab, p lab varwidth(60) wide nostar
	
	
	foreach var of varlist age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_scor{
		eststo: reg `var' i.treat i.sur_complete, cluster(school)
	}
	esttab, p
	eststo clear	
 
 	foreach var of varlist bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2{
		eststo: logit `var' i.treat i.sur_complete, cluster(school)
	}
	esttab, p
	eststo clear	 
 
* Retention at 12 months
	estpost tabstat age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if fu_sur_complete==1, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("Retained at 12 mths")
	eststo clear
	
	estpost tabstat age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score if fu_sur_complete==0, stat(mean sd min max n) columns(stat)
	esttab, cells("mean sd count") unstack replace varwidth(45) title("LTFU at 12 mths")
	eststo clear

	qui: estpost tabstat bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 if fu_sur_complete==1, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("Retained at 12 mths") varwidth(60)

	qui: estpost tabstat bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 if fu_sur_complete==0, stat(sum mean n) columns(stat)
	esttab, cells("sum mean count") label unstack replace title("LTFU at 12 mths") varwidth(60)
	
	 estpost ttest age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_score bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2 , by(fu_sur_complete)	
	esttab, p lab varwidth(60) wide nostar
	
	
	foreach var of varlist age_baseline bs_hiv_know_tot bs_num_partners_ever bs_shreya_scor{
		eststo: reg `var' i.treat i.fu_sur_complete, cluster(school)
	}
	esttab, p
	eststo clear	
 
 	foreach var of varlist bs_employed_income bs_food_insecure bs_sex_ever bs_gift_sex bs_fp_use_recent bs_ever_preg bs_preg_test bs_friend_preg bs_friend_abortion bs_sti_symp_any bs_hiv_test_ever bs_hiv_test_recent bs_hiv_pos2{
		eststo: logit `var' i.treat i.fu_sur_complete, cluster(school)
	}
	esttab, p
	eststo clear
 


//Table S8: Testing Rates at Graduation Event
tab1 HIVtest_grs fp_grs
	
	
//Table S9: Testing/Contraception at 6 vs 12 months
preserve
	lab var hiv_test_recent "HIV testing at 6 mths"
	lab var fu_hiv_test_recent "HIV testingat 12 mths"

	lab var fp_use_recent "FP at 6 mths"
	lab var fu_fp_use_recent "FP at 12 mths"

	tab hiv_test_recent fu_hiv_test_recent, row
	tab hiv_test_recent fu_hiv_test_recent, row mi

	tab fp_use_recent fu_fp_use_recent, row
	tab fp_use_recent fu_fp_use_recent, row mi

restore


//Figure S3: Heterogenous treatment effects by school
preserve
	collapse (mean)bs_hiv_test_recent (mean)hiv_test_recent (mean)fu_hiv_test_recent (mean)bs_fp_use_recent (mean)fp_use_recent (mean)fu_fp_use_recent (first)treat, by(school)
		format bs_hiv_test_recent %9.2f
		format hiv_test_recent %9.2f
		format fu_hiv_test_recent %9.2f
		
		format bs_fp_use_recent %9.2f
		format fu_fp_use_recent %9.2f
		format fp_use_recent %9.2f
		
		//HIV testing	
	gen change_test=hiv_test_recent-bs_hiv_test_recent
		format change_test %9.2f
		
	separate change_test, by(treat)
	
	gen change_test_12mth=fu_hiv_test_recent-bs_hiv_test_recent
		format change_test_12mth %9.2f
		
	separate change_test_12mth, by(treat)
		
		//Contraception
	gen change_fp=fp_use_recent-bs_fp_use_recent
		format change_fp %9.2f
		
	separate change_fp, by(treat)

	gen change_fp_12mth=fu_fp_use_recent-bs_fp_use_recent
		format change_fp_12mth %9.2f
		
	separate change_fp_12mth, by(treat)

	
	
	sum change_test change_test_12mth change_fp change_fp_12mth
		
	lab var change_test0 "Control"
	lab var change_test1 "Intervention"
		
	graph hbar change_test0 change_test1, nofill over(school, sort(change_test) descending) title("Change in 6mth HIV testing rates by school") legend(off) scheme(s2mono)
	graph save "${figures}change_testing_school_6mth.gph", replace

	graph hbar change_test_12mth0 change_test_12mth1, nofill over(school, sort(change_test_12mth) descending) title("Change in 12mth HIV testing rates by school") legend(off) scheme(s2mono)
	graph save "${figures}change_testing_school_12mth.gph", replace
		
	graph hbar change_fp0 change_fp1, nofill over(school, sort(change_fp) descending) title("Change in 6mth contraception by school") legend(off) scheme(s2mono)
	graph save "${figures}change_fp_school_6mth.gph", replace
	
	graph hbar change_fp_12mth0 change_fp_12mth1, nofill over(school, sort(change_fp_12mth) descending) title("Change in 12mth rates by school") legend(label(1 "Control") label(2 "Intervention")) scheme(s2mono)
	graph save "${figures}change_fp_school_12mth.gph", replace
	
	//Panel A
	graph combine "${figures}change_testing_school_6mth.gph" "${figures}change_testing_school_12mth.gph" "${figures}change_fp_school_6mth.gph" "${figures}change_fp_school_12mth.gph", saving("${figures}change_hiv_fp.gph", replace)
	
restore


** Restricting to those balanced sample of those with both baseline and follow-up measure
	//6mth HIV
preserve
	keep if hiv_test_recent!=. & bs_hiv_test_recent!=. 

	collapse (mean)bs_hiv_test_recent (mean)hiv_test_recent (mean)fu_hiv_test_recent (mean)bs_fp_use_recent (mean)fp_use_recent (mean)fu_fp_use_recent (first)treat, by(school)
		format bs_hiv_test_recent %9.2f
		format hiv_test_recent %9.2f
		format fu_hiv_test_recent %9.2f
		
	gen change_test=hiv_test_recent-bs_hiv_test_recent
		format change_test %9.2f
		
	separate change_test, by(treat)
	

	lab var change_test0 "Control"
	lab var change_test1 "Intervention"
		
	graph hbar change_test0 change_test1, nofill over(school, sort(change_test) descending) title("Change in 6mth HIV testing rates by school") legend(off) scheme(s2mono)
	graph save "${figures}change_testing_school_6mth_v2.gph", replace
	
restore

	//12mth HIV
preserve
	keep if fu_hiv_test_recent!=. & bs_hiv_test_recent!=. 

	collapse (mean)bs_hiv_test_recent (mean)hiv_test_recent (mean)fu_hiv_test_recent (mean)bs_fp_use_recent (mean)fp_use_recent (mean)fu_fp_use_recent (first)treat, by(school)
		format bs_hiv_test_recent %9.2f
		format hiv_test_recent %9.2f
		format fu_hiv_test_recent %9.2f
		
	gen change_test_12mth=fu_hiv_test_recent-bs_hiv_test_recent
		format change_test_12mth %9.2f
		
	separate change_test_12mth, by(treat)
	
		
	lab var change_test_12mth0 "Control"
	lab var change_test_12mth1 "Intervention"

	graph hbar change_test_12mth0 change_test_12mth1, nofill over(school, sort(change_test_12mth) descending) title("Change in 12mth HIV testing rates by school") legend(off) scheme(s2mono)
	graph save "${figures}change_testing_school_12mth_v2.gph", replace
		
restore
	
	//6mth FP
preserve
	keep if bs_fp_use_recent!=. & fp_use_recent!=.

	collapse (mean)bs_hiv_test_recent (mean)hiv_test_recent (mean)fu_hiv_test_recent (mean)bs_fp_use_recent (mean)fp_use_recent (mean)fu_fp_use_recent (first)treat, by(school)
		format bs_fp_use_recent %9.2f
		format fu_fp_use_recent %9.2f
		format fp_use_recent %9.2f

	gen change_fp=fp_use_recent-bs_fp_use_recent
		format change_fp %9.2f
		
	separate change_fp, by(treat)

	
		
	lab var change_fp0 "Control"
	lab var change_fp1 "Intervention"
		
	graph hbar change_fp0 change_fp1, nofill over(school, sort(change_fp) descending) title("Change in 6mth contraception by school") legend(off) scheme(s2mono)
	graph save "${figures}change_fp_school_6mth_v2.gph", replace
	
restore	

	//12mth FP
preserve
	keep if bs_fp_use_recent!=. & fu_fp_use_recent!=.
	
	collapse (mean)bs_hiv_test_recent (mean)hiv_test_recent (mean)fu_hiv_test_recent (mean)bs_fp_use_recent (mean)fp_use_recent (mean)fu_fp_use_recent (first)treat, by(school)
		
		format bs_fp_use_recent %9.2f
		format fu_fp_use_recent %9.2f
		format fp_use_recent %9.2f
	
	gen change_fp_12mth=fu_fp_use_recent-bs_fp_use_recent
		format change_fp_12mth %9.2f
		
	separate change_fp_12mth, by(treat)

	
	
	graph hbar change_fp_12mth0 change_fp_12mth1, nofill over(school, sort(change_fp_12mth) descending) title("Change in 12mth rates by school") legend(label(1 "Control") label(2 "Intervention")) scheme(s2mono)
	graph save "${figures}change_fp_school_12mth_v2.gph", replace
	
	
restore	
	
	//Panel B
	graph combine "${figures}change_testing_school_6mth_v2.gph" "${figures}change_testing_school_12mth_v2.gph" "${figures}change_fp_school_6mth_v2.gph" "${figures}change_fp_school_12mth.gph", saving("${figures}change_hiv_fp_v2.gph", replace)



 ************ *3. Impact on HIV testing and contraception************************************************************
//Controlling for baseline imbalances
	foreach var of varlist bs_shreya_score bs_employed_income{
		// Calculate the mean of the variable, excluding missing values
		quietly summarize `var', meanonly
		local mean = r(mean)
		
		// Replace missing values with the calculated mean
		gen `var'2=`var'
		replace `var'2 = `mean' if missing(`var')
		
		//Generate indicator for imputed variable
		gen `var'_imp=0
		replace `var'_imp=1 if missing(`var')
	}


local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

//Table 2: Impact of SKILLZ on HIV testing and contraception
* Unweighted
eststo: glm hiv_test_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post
	
	estadd ysumm
eststo: glm fu_hiv_test_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

	estadd ysumm
eststo: glm fp_use_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

	estadd ysumm
eststo: glm fu_fp_use_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

	estadd ysumm	
esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
eststo clear


*With IPTW
eststo: glm hiv_test_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fu_hiv_test_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fp_use_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fu_fp_use_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income). Weighted by stabilized inverse probability weights") varwidth(40) 
eststo clear

	

 ************ *4. Impact on adoption/discontinuation************************************************************
//Defining adoption and discontinuation variables
	* 6 mths
gen adopt_hiv_test=0 if bs_hiv_test_recent!=.
	replace adopt_hiv_test=1 if bs_hiv_test_recent==0 & hiv_test_recent==1
	
	lab var adopt_hiv_test "Adopted HIV testing at 6 months"

	//Revised denominator for discontinuation
gen discont_hiv_test=0 if bs_hiv_test_recent==1
	replace discont_hiv_test=1 if bs_hiv_test_recent==1 & hiv_test_recent==0

	lab var discont_hiv_test "Discontinued HIV testing at 6 months"
	
tab adopt_hiv_test treat, col	
tab discont_hiv_test treat, col
	
gen adopt_fp=0 if bs_fp_use_recent!=.
	replace adopt_fp=1 if bs_fp_use_recent==0 & fp_use_recent==1
	
	lab var adopt_fp "Adopted contraception at 6 months"

	//Revised denominator for discontinuation
gen discont_fp=0 if bs_fp_use_recent==1
	replace discont_fp=1 if bs_fp_use_recent==1 & fp_use_recent==0

	lab var discont_fp "Discontinued contraception at 6 months"
	
	tab adopt_fp treat, col
	tab discont_fp treat, col	
	
	*12 mths
gen fu_adopt_hiv_test=0 if bs_hiv_test_recent!=.
	replace fu_adopt_hiv_test=1 if bs_hiv_test_recent==0 & fu_hiv_test_recent==1
	
	lab var fu_adopt_hiv_test "Adopted HIV testing at 12 months"

	//Revised denominator for discontinuation
gen fu_discont_hiv_test=0 if bs_hiv_test_recent==1
	replace fu_discont_hiv_test=1 if bs_hiv_test_recent==1 & fu_hiv_test_recent==0

	lab var fu_discont_hiv_test "Discontinued HIV testing at 12 months"
	
tab fu_adopt_hiv_test treat, col	
tab fu_discont_hiv_test treat, col

	//Revised denominator for discontinuation	
gen fu_adopt_fp=0 if bs_fp_use_recent!=.
	replace fu_adopt_fp=1 if bs_fp_use_recent==0 & fu_fp_use_recent==1
	
	lab var fu_adopt_fp "Adopted contraception at 12 months"

gen fu_discont_fp=0 if bs_fp_use_recent==1
	replace fu_discont_fp=1 if bs_fp_use_recent==1 & fu_fp_use_recent==0

	lab var fu_discont_fp "Discontinued contraception at 12 months"
	
	tab fu_adopt_fp treat, col
	tab fu_discont_fp treat, col		

//Table 3: Adoption and discontinuation
local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

* Unweighted
eststo: glm adopt_hiv_test i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

eststo: glm fu_adopt_hiv_test i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post
	
eststo: glm discont_hiv_test i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

	estadd ysumm

eststo: glm fu_discont_hiv_test i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post
	
	
eststo: glm adopt_fp i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

	estadd ysumm	
eststo: glm fu_adopt_fp i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post
	
	estadd ysumm	
eststo: glm discont_fp i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

	estadd ysumm	
eststo: glm fu_discont_fp i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post


	estadd ysumm	
esttab, stats(ymean ysd r2 N) keep(*treat*)  lab eform ci mtitle("Adopt HIV 6mths" "Adopt HIV 12mths" "Discont HIV 6mths" "Discont HIV 12mths" "Adopt FP 6mths" "Adopt FP 12mths" "Discont FP 6mth" "Discont FP 12mths") title("Impact of SKILLZ on adoption/discontinuation (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on adoption and discontinuation of HIV testing/contraception. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
eststo clear




*With IPTW
* Unweighted
eststo: glm adopt_hiv_test i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post

eststo: glm fu_adopt_hiv_test i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm discont_hiv_test i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fu_discont_hiv_test i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
eststo: glm adopt_fp i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
eststo: glm fu_adopt_fp i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
eststo: glm discont_fp i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
eststo: glm fu_discont_fp i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("Adopt HIV 6mths" "Adopt HIV 12mths" "Discont HIV 6mths" "Discont HIV 12mths" "Adopt FP 6mths" "Adopt FP 12mths" "Discont FP 6mth" "Discont FP 12mths") title("Impact of SKILLZ on adoption/discontinuation (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on adoption and discontinuation of HIV testing/contraception. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
eststo clear


	
 ************ *5. Impact on specific testing modalities and contraceptive methods******************************
tab hiv_test_type_1 treat, col
tab hiv_bloodtest treat, col
	
	//Table 4
	lab val fp_recent_mfcondom fp_recent_larc yesno_lbl
	
	tab max_fp_use_recent_mod treat, col
	tab fp_recent_sarc treat, col
	
	tab fp_recent_mfcondom treat, col
	tab fp_recent_pill treat, col
	tab fp_recent_ec treat, col
	tab fp_recent_larc treat, col
	
	
	//Table 4: Impact of SKILLZ on specific HIV testing modalities
	local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp
	
	* Unweighted
		//HIV
	eststo: glm hiv_test_type_1 i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
			estadd ysumm
		
	eststo: glm fu_hiv_test_type_1 i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
	
	estadd ysumm
		
	eststo: glm hiv_bloodtest i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
				estadd ysumm
				
	eststo: glm fu_hiv_bloodtest i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post	
		
		estadd ysumm	
		

		esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIVST 6mths" "HIVST 12mths" "Blood 6mths" "Blood 12mths") title("Impact of SKILLZ on specific HIV testing modalities (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on HIV self testing and blood-based methods at 6 and 12 months. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear


	*With IPTW
		//HIV
	eststo: glm hiv_test_type_1 i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
			estadd ysumm
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
		

	eststo: glm fu_hiv_test_type_1 i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm hiv_bloodtest i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_bloodtest i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIVST 6mths" "HIVST 12mths" "Blood 6mths" "Blood 12mths") title("Impact of SKILLZ on specific HIV testing modalities (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on HIV self testing and blood-based methods at 6 and 12 months. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear

	* Unweighted
		//FP
	eststo: glm fp_recent_mfcondom i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
			estadd ysumm
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
	eststo: glm fu_fp_recent_mfcondom i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_recent_pill i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_pill i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	eststo: glm fp_recent_ec i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
		estadd ysumm
	eststo: glm fu_fp_recent_ec i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
		estadd ysumm	
	eststo: glm fp_recent_larc i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_larc i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("Cond 6mths" "Cond 12mths" "OC 6mths" "OC 12mths" "EC 6 mths" "EC 12mths" "LARC 6mth" "LARC 12mth") title("Impact of SKILLZ on specific contraceptive methods (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on condoms, oral contraception, emergency contraception, and long-acting contraception. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear

	* With IPTW
		//FP
	eststo: glm fp_recent_mfcondom i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
			estadd ysumm
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
	eststo: glm fu_fp_recent_mfcondom i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_recent_pill i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_pill i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	eststo: glm fp_recent_ec i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_ec i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	eststo: glm fp_recent_larc i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_larc i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
		
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("Cond 6mths" "Cond 12mths" "OC 6mths" "OC 12mths" "EC 6 mths" "EC 12mths" "LARC 6mth" "LARC 12mth") title("Impact of SKILLZ on specific contraceptive methods (modified poisson models IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on condoms, oral contraception, emergency contraception, and long-acting contraception. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear

	

 ************ *6. Appendices************************************************************
	//Appendix Table S2: additional methods
	tab fp_recent_withdrawal treat, col
	tab fp_recent_natural treat, col
	tab fp_recent_abs treat, col
	tab max_fp_use_recent_mod treat, col
		lab val max_fp_use_recent_mod fp_recent_abs yesno_lbl
		
	tab max_fp_use_recent treat, col	
	
	* Unweighted
		local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp
	
		//FP
	eststo: glm fp_recent_withdrawal i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
			estadd ysumm
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
	eststo: glm fu_fp_recent_withdrawal i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_recent_natural i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_natural i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	eststo: glm fp_recent_abs i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_abs i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	eststo: glm max_fp_use_recent_mod i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_max_fp_use_recent_mod i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) lab keep(*treat*) eform ci mtitle("Wthdrwl 6mths" "Wthdrwl 12mths" "Natural 6mths" "Natural 12mths" "Abst 6 mths" "Abst 12mths" "Modern 6mth" "Modern 12mth") title("Impact of SKILLZ on specific contraceptive methods (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on withdrawl, natural, abstinence, modern methods. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear
	
	* With IPTW
		local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp
	
		//FP
	eststo: glm fp_recent_withdrawal i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
			estadd ysumm
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
	eststo: glm fu_fp_recent_withdrawal i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_recent_natural i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_natural i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	eststo: glm fp_recent_abs i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_recent_abs i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	eststo: glm max_fp_use_recent_mod i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_max_fp_use_recent_mod i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) lab keep(*treat*) eform ci mtitle("Wthdrwl 6mths" "Wthdrwl 12mths" "Natural 6mths" "Natural 12mths" "Abst 6 mths" "Abst 12mths" "Modern 6mth" "Modern 12mth") title("Impact of SKILLZ on specific contraceptive methods (modified poisson models IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on withdrawl, natural, abstinence, modern methods. Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear
	
//Table S4: Restricting to Baseline only
preserve

keep if baseline_complete==1

tab treat

tab per_protocol_treat2 if treat==1
tab per_protocol_treat if treat==1

tab hiv_test_recent treat, col
tab fu_hiv_test_recent treat, col

tab fp_use_recent treat, col
tab fu_fp_use_recent treat, col


local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

	* Unweighted
	eststo: glm hiv_test_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
		
		estadd ysumm
	eststo: glm fu_hiv_test_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent i.treat `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear


	*With IPTW
	eststo: glm hiv_test_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_test_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent i.treat `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income). Weighted by stabilized inverse probability weights") varwidth(40) 
	eststo clear	


restore

//Table S5: Non-response bias
gen hiv_immputed=0
	replace hiv_immputed=1 if hiv_test_recent==.
	
gen fp_imputed=0
	replace fp_imputed=1 if fp_use_recent==.
	
gen fu_hiv_immputed=0
	replace fu_hiv_immputed=1 if fu_hiv_test_recent==.
	
gen fu_fp_imputed=0
	replace fu_fp_imputed=1 if fu_fp_use_recent==.	
	
	//Generating imputed outcome variables
	foreach var of varlist hiv_test_recent fu_hiv_test_recent fp_use_recent fu_fp_use_recent{
		sum `var'
		return list
		gen `var'_mean=r(mean)
		clonevar `var'_meanimp=`var'
			replace `var'_meanimp=`var'_mean if `var'_meanimp==.
		clonevar `var'_zeroimp=`var'
			replace `var'_zeroimp=0 if `var'_zeroimp==.
		clonevar `var'_oneimp=`var'
			replace `var'_oneimp=1 if `var'_oneimp==.
	}	
	
*Impute with Zeros
local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

	* Unweighted
	eststo: glm hiv_test_recent_zeroimp i.treat `bs_imb_var' i.hiv_immputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_test_recent_zeroimp i.treat `bs_imb_var' i.fu_hiv_immputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent_zeroimp i.treat `bs_imb_var' i.fp_imputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent_zeroimp i.treat `bs_imb_var' i.fu_fp_imputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear


	*With IPTW
	eststo: glm hiv_test_recent_zeroimp i.treat `bs_imb_var' i.hiv_immputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_test_recent_zeroimp i.treat `bs_imb_var' i.fu_hiv_immputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent_zeroimp i.treat `bs_imb_var' i.fp_imputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent_zeroimp i.treat `bs_imb_var' i.fu_fp_imputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income). Weighted by stabilized inverse probability weights") varwidth(40) 
	eststo clear	


*Impute with Ones	
local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

	* Unweighted
	eststo: glm hiv_test_recent_oneimp i.treat `bs_imb_var' i.hiv_immputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_test_recent_oneimp i.treat `bs_imb_var' i.fu_hiv_immputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent_oneimp i.treat `bs_imb_var' i.fp_imputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent_oneimp i.treat `bs_imb_var' i.fu_fp_imputed, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear


	*With IPTW
	eststo: glm hiv_test_recent_oneimp i.treat `bs_imb_var' i.hiv_immputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_test_recent_oneimp i.treat `bs_imb_var' i.fu_hiv_immputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent_oneimp i.treat `bs_imb_var' i.fp_imputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent_oneimp i.treat `bs_imb_var' i.fu_fp_imputed [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income). Weighted by stabilized inverse probability weights") varwidth(40) 
	eststo clear	
	
//Table S7: Timing of enrollment
	//a) Additional enrollment indicator
local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

	* Unweighted
	eststo: glm hiv_test_recent i.treat `bs_imb_var' i.add_enrol, fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
		
		estadd ysumm
	eststo: glm fu_hiv_test_recent i.treat `bs_imb_var' i.add_enrol, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent i.treat `bs_imb_var' i.add_enrol, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent i.treat `bs_imb_var' i.add_enrol, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear


	*With IPTW
	eststo: glm hiv_test_recent i.treat `bs_imb_var' i.add_enrol [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_test_recent i.treat `bs_imb_var' i.add_enrol [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent i.treat `bs_imb_var' i.add_enrol [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent i.treat `bs_imb_var' i.add_enrol [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) keep(*treat*) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income). Weighted by stabilized inverse probability weights") varwidth(40) 
	eststo clear	

	
	
	//b) Month of enrolment
	clonevar date_enrollment=date_baseline

	gen month_enrollment=month(date_enrollment)
	gen year_enrollment=year(date_enrollment)
	
	tab month_enrollment year_enrollment
	replace month_enrollment=month_enrollment+12 if year==2022	
	
local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

	* Unweighted
	eststo: glm hiv_test_recent i.treat `bs_imb_var' i.month_enrollment, fam(poisson) link(log) vce(cluster school) eform
		margins treat, post
		nlcom (rd: _b[1.treat] - _b[0.treat]), post
		
		estadd ysumm
	eststo: glm fu_hiv_test_recent i.treat `bs_imb_var' i.month_enrollment, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent i.treat `bs_imb_var' i.month_enrollment, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent i.treat `bs_imb_var' i.month_enrollment, fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
	eststo clear


	*With IPTW
	eststo: glm hiv_test_recent i.treat `bs_imb_var' i.month_enrollment [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_hiv_test_recent i.treat `bs_imb_var' i.month_enrollment [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fp_use_recent i.treat `bs_imb_var' i.month_enrollment [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm
	eststo: glm fu_fp_use_recent i.treat `bs_imb_var' i.month_enrollment [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
		estadd ysumm	
	esttab, stats(ymean ysd r2 N) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income). Weighted by stabilized inverse probability weights") varwidth(40) 
	eststo clear	
	
//Table S3: diff-in-diff
//Constructing diff-in-diff structure
preserve

keep bs_hiv_test_recent bs_fp_use_recent treat stabIPW school age_6mth ptid bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp

	rename bs_hiv_test_recent hiv_test_recent
	rename bs_fp_use_recent fp_use_recent

	clonevar fu_hiv_test_recent=hiv_test_recent
	clonevar fu_fp_use_recent=fp_use_recent
	
	gen post=0

	tempfile baseline_outcomes
	save `baseline_outcomes', replace

restore	 

append using `baseline_outcomes', gen(baseline_outcome)	
replace post=1 if baseline_outcome==0	
	
encode ptid, gen(ptid_num)
xtset ptid_num post

gen treatpost=treat*post	
	
	
	//Table S3: diff-in-diff
local bs_imb_var bs_shreya_score2 bs_shreya_score_imp bs_employed_income2 bs_employed_income_imp
	
	
* Unweighted
eststo: glm hiv_test_recent i.treat##i.post `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	margins treat, post
	nlcom (rd: _b[1.treat] - _b[0.treat]), post
	
	estadd ysumm
eststo: glm fu_hiv_test_recent i.treat##i.post `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fp_use_recent i.treat##i.post `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fu_fp_use_recent i.treat##i.post `bs_imb_var', fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
esttab, stats(ymean ysd r2 N) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income)") varwidth(40) 
eststo clear


*With IPTW
eststo: glm hiv_test_recent i.treat##i.post `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fu_hiv_test_recent i.treat##i.post `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fp_use_recent i.treat##i.post `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm
eststo: glm fu_fp_use_recent i.treat##i.post `bs_imb_var' [pweight=stabIPW], fam(poisson) link(log) vce(cluster school) eform
	estadd ysumm	
esttab, stats(ymean ysd r2 N) lab eform ci mtitle("HIV 6mths" "HIV 12mths" "FP 6mths" "FP 12mths") title("Impact of SKILLZ on primary outcomes (modified poisson models, IPTW)") note("Modified poisson estimates of SKILLZ treatment assignment on recent HIV testing at 6 and 12 months (Models 1 and 2) and contraception at 6 and 12 months (Models 3 and 4). Standard errors are clustered at the school level. All models adjust for characteristics with chance imbalances at baseline (Shreya Empowerment Score and Emloyed/Earns Income). Weighted by stabilized inverse probability weights") varwidth(40) 
eststo clear	
	
	
capture log close












